package lumis.service.wsrp.consumer;

import lumis.portal.PortalException;
import lumis.service.wsrp.consumer.producermanager.ProducerEntityImpl;

/**
 * Factory for remote service manager.
 *
 * @version $Revision: 13092 $ $Date: 2011-05-28 18:19:06 -0300 (Sat, 28 May 2011) $
 * @since 6.0.0
 */
public class RemoteServiceManagerFactory
{
	/**
	 * Retrieves the RemotePortletManagmentManager for the given producerEntity.
	 * @param producerEntity producer entity to get the RemotePortletManagmentManager of.
	 * @return the RemotePortletManagmentManager of the correct version for the producerEntity. 
	 * @throws PortalException if the entity version is not correct.
	 */
	public RemotePortletManagementManager getRemotePortletManagementManager(ProducerEntityImpl producerEntity) throws PortalException
	{	
		if (producerEntity.getEntityVersion() == 1)
		{
			return new RemotePortletManagementManagerV1(producerEntity.getURL(), producerEntity.getRegistrationContext());
		}
		else if (producerEntity.getEntityVersion() == 2)
		{
			return new RemotePortletManagementManagerV2(producerEntity.getURL(), producerEntity.getRegistrationContext());
		}
		
		throw new PortalException("STR_INVALID_WSRP_VERSION");
	}
}